/**
 * @file     canJump.ts
 * @brief    [55. 跳跃游戏](https://leetcode.cn/problems/jump-game/description/)
 * @author   Zhu
 * @date     2022-11-16 22:25
 */

function canJump(nums: number[]): boolean {
    let maxStep = 0;
    for (let i = 0; i < nums.length; i++) {
        if (i > maxStep) return false;

        const curStep = nums[i] + i;
        if (curStep > maxStep) maxStep = curStep;
    }

    return true;
}
